ImageGear Professional for Unix
Converting and Displaying an Image DDB

There are several internal formats used in the ImageGear library to represent an image, and there are groups of functions that allow you to convert it to an Xlib-compatible DDB (Pixmap) file, and back to its original format. Creating a DDB displays an image on a pixmap (not on a window). All display-related parameters are used in a DDB display the same way that they are used for displaying an image in a window.

Use the IG_dspl_DDB_create() function to create a pixmap object from a HIGEAR image function. This function accepts a HIGEAR image and the pixmap’s width and height as input, and returns a pixmap object as output. You can optionally remove the source HIGEAR object after creating the object.

To draw a pixmap, use either the standard Xlib functions or ImageGear’s IG_dspl_DDB_draw() function.

The following are segments from the Filters sample that demonstrate how an image is loaded (dlg_open.c):

 
Copy Code
AT_ERRCOUNT dlgOpenLoadPage(LPCHAR lpFileName, UINT nPage, LPHIGEAR lphIGear)
{
int fd;
AT_ERRCOUNT nErrCount;
LPVOID lpPrivate;
LPFNIG_ERRSTACK_ADD lpCBFunc;
LPFNIG_ERRSTACK_CLEAR lpCBFunc2;
fd = open( (char*)lpFileName, O_RDONLY );
if( fd>0 )
{
IG_err_callback_get( &lpPrivate, &lpCBFunc, &lpCBFunc2 );
IG_err_callback_set( NULL, NULL, NULL );
IG_err_callback_set( lpPrivate, lpCBFunc, lpCBFunc2 );
nErrCount = IG_load_FD( fd, 0, nPage, 0, lphIGear );
close( fd );
}else
{
nErrCount = 1;
*lphIGear = (HIGEAR)NULL;
}
return nErrCount;
}

and converted to a pixmap and back to HIGEAR (filters.c):

 
Copy Code
void mnuView_callback( Widget w, XtPointer data, XtPointer call_data )
{
AT_DIMENSION width, height;
int item_no = (int)data;
switch( item_no )
{
...
case 2: /* To Pixmap */
IG_image_dimensions_get( hIGear, &width, &height, NULL );
IG_dspl_DDB_create( hIGear, IG_GRP_DEFAULT, NULL, width, height, TRUE, &hPixmap,
&hPalette );
hIGear = (HIGEAR)NULL;
ImageViewUpdate();
break;
case 3: /* From Pixmap */
IG_dspl_DDB_import( NULL, hPixmap, hPalette, &hIGear );
ImageViewUpdate();
break;
...
}}

and how to draw a pixmap (filters.c):

 
Copy Code

void wndDrawImage_callback( Widget w, XtPointer data, XtPointer call_data )
{
XmDrawingAreaCallbackStruct*cbs =
(XmDrawingAreaCallbackStruct*)call_data;
XExposeEvent*event = (XExposeEvent*)cbs->event;
AT_RECTANGLE UpdateRect;
if( hPixmap!=NULL )
{
IG_dspl_DDB_draw( XtWindow(w), XDefaultGCOfScreen(XtScreen(w)), hPixmap,
hPalette, 0, 0 );
}}

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback